<?php
namespace Home\Model;
use Think\Model;
class NewsModel extends Model {

    protected $_validate = [
       // array('content','require','内容必须！'),
       array('content','checkContent','长度必须大于10个字符',1,'callback'), 
       array('session','checkSession','请先登录!',1,'callback'), 
    ] ;

    protected $_auto = [

    ] ;

    protected function getTime(){
            return date('Y-m-d H:i:s');
    }

    // 验证是否登录
    protected function checkSession()
    {
        redirect('login');
        return !empty($_SESSION['uid']);
    }

    // 验证内容长度
    protected function checkContent($content)
    {
        return strlen($content) > 10;
    }
}